comparison libinterp/dldfcn/audiodevinfo.cc @ 19590:d7057df2968e

use existing function to determine endianness in audiodevinfo.cc * audiodevinfo.cc (is_big_endian): Delete. (octave_play_callback, portaudio_play_callback): Use oct_mach_info::words_big_endian instead of local big_endian function.
author John W. Eaton <jwe@octave.org>
date Fri, 09 Jan 2015 13:25:52 -0500
parents 9bd2f0a07c95
children 182abae666ae
comparison
equal deleted inserted replaced
19589:9bd2f0a07c95 19590:d7057df2968e
27 // <cstdint> requires c++11 27 // <cstdint> requires c++11
28 #include <stdint.h> 28 #include <stdint.h>
29 29
30 #include <string> 30 #include <string>
31 #include <vector> 31 #include <vector>
32
33 #include "mach-info.h"
32 34
33 #include "defun-dld.h" 35 #include "defun-dld.h"
34 #include "error.h" 36 #include "error.h"
35 #include "gripes.h" 37 #include "gripes.h"
36 #include "oct-obj.h" 38 #include "oct-obj.h"
513 static const unsigned int BUFFER_SIZE = 8192; 515 static const unsigned int BUFFER_SIZE = 8192;
514 516
515 DEFINE_OCTAVE_ALLOCATOR (audioplayer); 517 DEFINE_OCTAVE_ALLOCATOR (audioplayer);
516 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (audioplayer, "audioplayer", "audioplayer"); 518 DEFINE_OV_TYPEID_FUNCTIONS_AND_DATA (audioplayer, "audioplayer", "audioplayer");
517 519
518 int
519 is_big_endian (void)
520 {
521 union
522 {
523 uint32_t i;
524 char c[4];
525 } bint = { 0x01020304 };
526 return bint.c[0] == 1;
527 }
528
529 static int 520 static int
530 octave_play_callback (const void *, void *output, unsigned long frames, 521 octave_play_callback (const void *, void *output, unsigned long frames,
531 const PaStreamCallbackTimeInfo *, 522 const PaStreamCallbackTimeInfo *,
532 PaStreamCallbackFlags, void *data) 523 PaStreamCallbackFlags, void *data)
533 { 524 {
601 592
602 case 24: 593 case 24:
603 { 594 {
604 static double scale_factor = pow (2.0, 23) - 1.0; 595 static double scale_factor = pow (2.0, 23) - 1.0;
605 596
606 static int big_endian = is_big_endian (); 597 static int big_endian = oct_mach_info::words_big_endian ();
607 598
608 uint8_t *buffer = static_cast<uint8_t *> (output); 599 uint8_t *buffer = static_cast<uint8_t *> (output);
609 600
610 for (unsigned long i = 0; i < frames; i++) 601 for (unsigned long i = 0; i < frames; i++)
611 { 602 {
717 708
718 case 24: 709 case 24:
719 { 710 {
720 static double scale_factor = pow (2.0, 23) - 1.0; 711 static double scale_factor = pow (2.0, 23) - 1.0;
721 712
722 static int big_endian = is_big_endian (); 713 static int big_endian = oct_mach_info::words_big_endian ();
723 714
724 uint8_t *buffer = static_cast<uint8_t *> (output); 715 uint8_t *buffer = static_cast<uint8_t *> (output);
725 716
726 for (unsigned long j = 0; j < frames; j++) 717 for (unsigned long j = 0; j < frames; j++)
727 { 718 {