Changeset 195 for libmpc/branches/r2d/mpcenc/wave_in.c
- Timestamp:
- 12/29/06 15:21:35 (18 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
libmpc/branches/r2d/mpcenc/wave_in.c
r171 r195 32 32 #endif 33 33 34 35 #if defined USE_OSS_AUDIO || defined USE_ESD_AUDIO || defined USE_SUN_AUDIO36 static void37 Set_Realtime ( void )38 {39 # if defined USE_NICE40 seteuid ( 0 );41 setpriority ( PRIO_PROCESS, getpid(), -20 );42 seteuid ( getuid() );43 # endif44 }45 #endif /* USE_OSS_AUDIO || USE_ESD_AUDIO || USE_SUN_AUDIO */46 47 48 34 #define EXT(x) (0 == strcasecmp (ext, #x)) 49 35 … … 59 45 fp = SETBINARY_IN ( stdin ); 60 46 } 61 #ifndef _WIN3262 #ifndef NO_DEV_AUDIO63 else if ( 0 == strncmp ( filename, "/dev/", 5) ) {64 int fd;65 int arg;66 int org;67 68 fd = open (filename, O_RDONLY);69 if ( fd < 0 )70 return -1;71 72 type->Channels = org = arg = 2;73 if ( -1 == ioctl ( fd, SOUND_PCM_WRITE_CHANNELS, &arg ) )74 return -1;75 if (arg != org)76 return -1;77 78 type->BitsPerSample = org = arg = 16;79 type->BytesPerSample = 2;80 if ( -1 == ioctl ( fd, SOUND_PCM_WRITE_BITS, &arg ) )81 return -1;82 if (arg != org)83 return -1;84 85 org = arg = AFMT_S16_LE;86 if ( -1 == ioctl ( fd, SNDCTL_DSP_SETFMT, &arg ) )87 return -1;88 if ((arg & org) == 0)89 return -1;90 91 type->SampleFreq = org = arg = 44100.;92 if ( -1 == ioctl ( fd, SOUND_PCM_WRITE_RATE, &arg ) )93 return -1;94 if ( 23.609375 * abs(arg-org) > abs(arg+org) ) // Sample frequency: Accept 40.5...48.0 kHz for 44.1 kHz95 return -1;96 97 type->raw = 1;98 type->PCMOffset = 0;99 type->PCMBytes = 0xFFFFFFFF;100 type->PCMSamples = 86400 * type->SampleFreq;101 102 fp = fdopen (fd, "rb");103 Set_Realtime ();104 }105 #endif106 #else107 else if ( 0 == strncmp ( filename, "/dev/audio", 10 ) ) {108 int tmp;109 int fs = 44100;110 double dur = 86400.;111 112 sscanf ( filename, "%*[^:]:%u:%lf", &fs, &dur );113 114 fp = (FILE*)-1;115 type -> Channels = 2;116 type -> BitsPerSample = 16;117 type -> BytesPerSample = 2;118 type -> SampleFreq = fs;119 type -> PCMOffset = 0;120 type -> PCMBytes = 0xFFFFFFFF;121 type -> PCMSamples = dur * type -> SampleFreq;122 type -> raw = 1;123 tmp = init_in ( 1152, (int) floor (type -> SampleFreq + 0.5), type -> Channels, type -> BitsPerSample );124 if ( tmp )125 return -1;126 # if defined USE_REALTIME127 SetPriorityClass ( GetCurrentProcess (), REALTIME_PRIORITY_CLASS );128 # elif defined USE_NICE129 SetPriorityClass ( GetCurrentProcess (), HIGH_PRIORITY_CLASS );130 # endif131 }132 #endif133 47 else if ( ext == NULL ) { 134 48 fp = NULL; … … 454 368 if (type->PCMBytes >= 0xFFFFFF00 || 455 369 type->PCMBytes == 0 || 456 ( Uint32_t)type->PCMBytes % (type -> Channels * type->BytesPerSample) != 0) {370 (mpc_uint32_t)type->PCMBytes % (type -> Channels * type->BytesPerSample) != 0) { 457 371 type->PCMSamples = 36000000 * type->SampleFreq; 458 372 }
Note: See TracChangeset
for help on using the changeset viewer.