~ubuntu-branches/ubuntu/wily/alsaplayer/wily

« back to all changes in this revision

Viewing changes to app/CorePlayer.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Hubert Chathi
  • Date: 2007-10-10 15:33:10 UTC
  • mto: (9.2.5 sid)
  • mto: This revision was merged to the branch mainline in revision 15.
  • Revision ID: james.westby@ubuntu.com-20071010153310-h3holq75eu2cigb0
Tags: upstream-0.99.80~rc4
ImportĀ upstreamĀ versionĀ 0.99.80~rc4

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*  CorePlayer.cpp - Core player object, most of the hacking is done here!  
2
2
 *      Copyright (C) 1998-2003 Andy Lo A Foe <andy@alsaplayer.org>
3
3
 *
4
 
 *  This program is free software; you can redistribute it and/or modify
 
4
 *  This file is part of AlsaPlayer.
 
5
 *
 
6
 *  AlsaPlayer is free software; you can redistribute it and/or modify
5
7
 *  it under the terms of the GNU General Public License as published by
6
 
 *  the Free Software Foundation; either version 2 of the License, or
 
8
 *  the Free Software Foundation; either version 3 of the License, or
7
9
 *  (at your option) any later version.
8
10
 *
9
 
 *  This program is distributed in the hope that it will be useful,
 
11
 *  AlsaPlayer is distributed in the hope that it will be useful,
10
12
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
11
13
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
12
14
 *  GNU General Public License for more details.
13
15
 *
14
16
 *  You should have received a copy of the GNU General Public License
15
 
 *  along with this program; if not, write to the Free Software
16
 
 *  Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
17
 
 *
18
 
 *
19
 
 *  $Id: CorePlayer.cpp 1114 2007-05-19 10:22:25Z dominique_libre $
 
17
 *  along with this program; if not, see <http://www.gnu.org/licenses/>.
 
18
 *
 
19
 *  $Id: CorePlayer.cpp 1267 2007-07-09 20:14:22Z dominique_libre $
20
20
 *
21
21
*/ 
22
22
 
132
132
        UnlockNotifiers();
133
133
}
134
134
 
135
 
 
 
135
// some arch don't define PATH_MAX
 
136
#ifndef PATH_MAX
 
137
#define PATH_MAX 1024
 
138
#endif
136
139
 
137
140
void CorePlayer::load_input_addons()
138
141
{
139
 
        char path[1024];
 
142
        char path[PATH_MAX];
 
143
        
140
144
        DIR *dir;
141
145
        struct stat buf;
142
146
        dirent *entry;
339
343
        int error_count = 0;
340
344
        input_plugin *tmp;
341
345
 
 
346
        if (the_plugin->name == NULL) {
 
347
                alsaplayer_error("No name");
 
348
                error_count++;
 
349
        }
 
350
        if (the_plugin->author == NULL) {
 
351
                alsaplayer_error("No author");
 
352
                error_count++;
 
353
        }       
 
354
        if (the_plugin->init == NULL) {
 
355
                alsaplayer_error("No init function");
 
356
                error_count++;
 
357
        }
 
358
        if (the_plugin->can_handle == NULL) {
 
359
                alsaplayer_error("No can_handle function");
 
360
                error_count++;
 
361
        }
 
362
        if (the_plugin->open == NULL) {
 
363
                alsaplayer_error("No open function");
 
364
                error_count++;
 
365
        }
 
366
        if (the_plugin->close == NULL) {
 
367
                alsaplayer_error("No close function");
 
368
                error_count++;
 
369
        }
 
370
        if (the_plugin->play_frame == NULL) {
 
371
                alsaplayer_error("No play_frame function");
 
372
                error_count++;
 
373
        }       
 
374
        if (the_plugin->frame_seek == NULL) {
 
375
                alsaplayer_error("No frame_seek function");
 
376
                error_count++;
 
377
        }
 
378
 
 
379
        if (the_plugin->nr_frames == NULL) {
 
380
                alsaplayer_error("No nr_frames function");
 
381
                error_count++;
 
382
        }
 
383
        if (the_plugin->frame_size == NULL) {
 
384
                alsaplayer_error("No frame_size function");
 
385
                error_count++;
 
386
        }
 
387
        if (the_plugin->channels == NULL) {
 
388
                alsaplayer_error("No channels function");
 
389
                error_count++;
 
390
        }       
 
391
        if (the_plugin->stream_info == NULL) {
 
392
                alsaplayer_error("No stream_info function");
 
393
                error_count++;
 
394
        }
 
395
        if (the_plugin->shutdown == NULL) {
 
396
                alsaplayer_error("No shutdown function");
 
397
                error_count++;
 
398
        }
 
399
        if (error_count) {
 
400
                alsaplayer_error("At least %d error(s) were detected", error_count);
 
401
                return 0;
 
402
        }
 
403
        
342
404
        tmp = &plugins[plugin_count];
343
405
        tmp->version = the_plugin->version;
344
406
        if (tmp->version) {
346
408
                        alsaplayer_error("Wrong version number on plugin (v%d, wanted v%d)",
347
409
                                        version - INPUT_PLUGIN_BASE_VERSION,
348
410
                                        INPUT_PLUGIN_VERSION - INPUT_PLUGIN_BASE_VERSION);      
349
 
                        return 0;
 
411
                        // this is a minor error actually 
 
412
                        // no need to stop there
 
413
//                      return 0;
350
414
                }
351
415
        }
 
416
 
352
417
        tmp->name = the_plugin->name;
353
418
        tmp->author = the_plugin->author;
354
419
        tmp->init = the_plugin->init;
366
431
        tmp->shutdown = the_plugin->shutdown;
367
432
        tmp->nr_tracks = the_plugin->nr_tracks;
368
433
        tmp->track_seek = the_plugin->track_seek;
369
 
        if (tmp->name == NULL) {
370
 
                alsaplayer_error("No name");
371
 
                error_count++;
372
 
        }
373
 
        if (tmp->author == NULL) {
374
 
                alsaplayer_error("No author");
375
 
                error_count++;
376
 
        }       
377
 
        if (tmp->init == NULL) {
378
 
                alsaplayer_error("No init function");
379
 
                error_count++;
380
 
        }
381
 
        if (tmp->can_handle == NULL) {
382
 
                alsaplayer_error("No can_handle function");
383
 
                error_count++;
384
 
        }
385
 
        if (tmp->open == NULL) {
386
 
                alsaplayer_error("No open function");
387
 
                error_count++;
388
 
        }
389
 
        if (tmp->close == NULL) {
390
 
                alsaplayer_error("No close function");
391
 
                error_count++;
392
 
        }
393
 
        if (tmp->play_frame == NULL) {
394
 
                alsaplayer_error("No play_frame function");
395
 
                error_count++;
396
 
        }       
397
 
        if (tmp->frame_seek == NULL) {
398
 
                alsaplayer_error("No frame_seek function");
399
 
                error_count++;
400
 
        }
401
 
 
402
 
        if (tmp->nr_frames == NULL) {
403
 
                alsaplayer_error("No nr_frames function");
404
 
                error_count++;
405
 
        }
406
 
        if (tmp->frame_size == NULL) {
407
 
                alsaplayer_error("No frame_size function");
408
 
                error_count++;
409
 
        }
410
 
        if (tmp->channels == NULL) {
411
 
                alsaplayer_error("No channels function");
412
 
                error_count++;
413
 
        }       
414
 
        if (tmp->stream_info == NULL) {
415
 
                alsaplayer_error("No stream_info function");
416
 
                error_count++;
417
 
        }
418
 
        if (tmp->shutdown == NULL) {
419
 
                alsaplayer_error("No shutdown function");
420
 
                error_count++;
421
 
        }
422
 
        if (error_count) {
423
 
                alsaplayer_error("At least %d error(s) were detected", error_count);
424
 
                //Unlock();
425
 
                return 0;
426
 
        }
 
434
        
427
435
        if (!tmp->init()) {
428
 
                alsaplayer_error("Plugin failed to initialize (\"%s\")",
429
 
                                tmp->name);
 
436
                alsaplayer_error("Plugin failed to initialize (\"%s\")", tmp->name);
430
437
                return 0;
431
438
        }       
432
439
        plugin_count++;
433
 
        if (plugin_count == 1) { // First so assign plugin
434
 
                //plugin = tmp;
435
 
        }
 
440
        
436
441
        if (global_verbose)
437
442
                alsaplayer_error("Loading Input plugin: %s", tmp->name);
438
443
 
590
595
        last_read = -1;
591
596
        output_rate = node->SamplingRate();
592
597
        input_rate = plugin->sample_rate(the_object);
593
 
        
 
598
 
594
599
        if (input_rate == output_rate)
595
600
                SetSpeedMulti(1.0);
596
601
        else
752
757
{
753
758
        if (repitched) { // Pitch was changed so return this instead
754
759
                return pitch_point;
755
 
        }       
756
 
        return (read_direction == DIR_FORWARD ? pitch : -pitch);
 
760
        }
 
761
        float ret_pitch = pitch / pitch_multi;
 
762
        return (read_direction == DIR_FORWARD ? ret_pitch : -ret_pitch);
757
763
}
758
764
 
759
765